package com.api.shopapi.service.impl;

import com.api.shopapi.entity.DeviceQzXuetangyi;
import com.api.shopapi.entity.dto.DeviceQzXuetangyiDTO;
import com.api.shopapi.mapper.DeviceQzXuetangyiMapper;
import com.api.shopapi.service.DeviceQzXuetangyiService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("DeviceQzXuetangyiServiceImplOne")
public class DeviceQzXuetangyiServiceImpl implements DeviceQzXuetangyiService {

    @Autowired
    private DeviceQzXuetangyiMapper deviceQzXuetangyiMapper;

    @Override
    public int insert(DeviceQzXuetangyi deviceQzXuetangyi) {
        return deviceQzXuetangyiMapper.insert(deviceQzXuetangyi);
    }

    @Override
    public int update(DeviceQzXuetangyi deviceQzXuetangyi) {
        return deviceQzXuetangyiMapper.update(deviceQzXuetangyi);
    }

    @Override
    public DeviceQzXuetangyi getByUserCode(String userCode) {
        return deviceQzXuetangyiMapper.getByUserCode(userCode);
    }

    @Override
    public DeviceQzXuetangyi getBySN(String SN) {
        return deviceQzXuetangyiMapper.getBySN(SN);
    }

    @Override
    public PageInfo<DeviceQzXuetangyiDTO> getPage(int pageIndex, int pageSize, String phone, String sn) {
        PageHelper.startPage(pageIndex,pageSize);
        List<DeviceQzXuetangyiDTO> deviceQzXuetangyiDTOList = deviceQzXuetangyiMapper.getPage(phone, sn);
        return new PageInfo<>(deviceQzXuetangyiDTOList);
    }
}
